<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2021/12/14
 * Time: 10:16
 */

require '../tools/DbTools.php';

$oldmoney = $_POST['oldmoney'];
$addmoney = $_POST['addmoney'];
$newmoney = $oldmoney+$addmoney;

session_start();
$usreInfo = $_SESSION[$_COOKIE['Token']];
$CardId = $usreInfo['CardId'];

DbTools::InitDb();
$sql = "INSERT INTO cardexchange(CardId,MoneyInBank,MoneyOutBank,ExchangeTime) VALUES($CardId,$addmoney,0,NOW())";
$resutl = DbTools::noSelect($sql);
$sql1 = "UPDATE bankcard set CardMoney = $newmoney  WHERE CardId = $CardId";
$resutl1 = DbTools::noSelect($sql1);
if($resutl['status'] && $resutl1['status']){
    echo '存钱成功';
    echo '<br />';
    echo '<a href="../user/userInfo.php">返回</a>';
}else{
    echo '存钱失败： '.$resutl['message'].$resutl1['status'];
}




